 package tools.packet;

 import client.MapleCharacter;
 import client.MapleStat;
 import client.inventory.MaplePet;
 import handling.opcode.EffectOpcode;
 import handling.opcode.SendPacketOpcode;
 import java.awt.Point;
 import java.util.List;
 import server.movement.LifeMovementFragment;
 import tools.data.output.MaplePacketLittleEndianWriter;


 public class PetPacket
 {
   public static byte[] showPetPickUpMsg(boolean canPickup, int pets) {
/*  17 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/*  19 */     mplew.writeShort(SendPacketOpcode.PET_PICKUP_MSG.getValue());
/*  20 */     mplew.write(canPickup ? 1 : 0);
/*  21 */     mplew.write(pets);

/*  23 */     return mplew.getPacket();
   }

   public static byte[] showPetAutoEatMsg() {
/*  27 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/*  29 */     mplew.writeShort(SendPacketOpcode.PET_AUTO_EAT_MSG.getValue());

/*  31 */     return mplew.getPacket();
   }

   public static byte[] showPet(MapleCharacter chr, MaplePet pet, boolean remove, boolean hunger) {
/*  35 */     return showPet(chr, pet, remove, hunger, false);
   }

   public static byte[] showPet(MapleCharacter chr, MaplePet pet, boolean remove, boolean hunger, boolean show) {
/*  39 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/*  41 */     mplew.writeShort(show ? SendPacketOpcode.SHOW_PET.getValue() : SendPacketOpcode.SPAWN_PET.getValue());
/*  42 */     mplew.writeInt(chr.getId());
/*  43 */     mplew.writeInt(chr.getPetIndex(pet));
/*  44 */     mplew.write(remove ? 0 : 1);






/*  51 */     mplew.write(hunger ? 1 : 1);
/*  52 */     if (!remove) {
/*  53 */       addPetInfo(mplew, chr, pet, false);
     }

/*  56 */     return mplew.getPacket();
   }

   public static void addPetInfo(MaplePacketLittleEndianWriter mplew, MapleCharacter chr, MaplePet pet, boolean showpet) {
/*  60 */     if (showpet) {
/*  61 */       mplew.write(1);
/*  62 */       mplew.writeInt(chr.getPetIndex(pet));
     }
/*  64 */     mplew.writeInt(pet.getPetItemId());
/*  65 */     mplew.writeMapleAsciiString(pet.getName());
/*  66 */     mplew.writeLong(pet.getUniqueId());
/*  67 */     mplew.writePos(pet.getPos());
/*  68 */     mplew.write(pet.getStance());
/*  69 */     mplew.writeShort(pet.getFh());
/*  70 */     mplew.writeInt(-1);

/*  72 */     mplew.writeShort(100);
/*  73 */     mplew.write(0);
/*  74 */     mplew.write(0);
/*  75 */     mplew.write(0);
/*  76 */     mplew.write(0);
   }















   public static byte[] movePet(int chrId, int slot, int v169, int tEncodedGatherDuration, Point startPos, Point velPos, List<LifeMovementFragment> moves) {
/*  94 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/*  96 */     mplew.writeShort(SendPacketOpcode.MOVE_PET.getValue());
/*  97 */     mplew.writeInt(chrId);
/*  98 */     mplew.writeInt(slot);
/*  99 */     PacketHelper.serializeMovementList(mplew, v169, tEncodedGatherDuration, startPos, velPos, moves);

/* 101 */     return mplew.getPacket();
   }

   public static byte[] petChat(int chaId, short act, String text, short slot) {
/* 105 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 107 */     mplew.writeShort(SendPacketOpcode.PET_CHAT.getValue());
/* 108 */     mplew.writeInt(chaId);
/* 109 */     mplew.writeInt(slot);
/* 110 */     mplew.writeShort(act);
/* 111 */     mplew.writeMapleAsciiString(text);

/* 113 */     return mplew.getPacket();
   }

   public static byte[] commandResponse(int chrId, byte command, short slot, boolean success, boolean food) {
/* 117 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 119 */     mplew.writeShort(SendPacketOpcode.PET_COMMAND.getValue());
/* 120 */     mplew.writeInt(chrId);
/* 121 */     mplew.writeInt(slot);
/* 122 */     mplew.write(food ? 2 : 1);
/* 123 */     mplew.write(command);
/* 124 */     if (food) {
/* 125 */       mplew.writeInt(0);
     } else {
/* 127 */       mplew.writeShort(success ? 1 : 0);
     }
/* 129 */     return mplew.getPacket();
   }

   public static byte[] showPetLevelUp(MapleCharacter chr, byte index) {
/* 133 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 135 */     mplew.writeShort(SendPacketOpcode.SHOW_FOREIGN_EFFECT.getValue());
/* 136 */     mplew.writeInt(chr.getId());
/* 137 */     mplew.write(EffectOpcode.UserEffect_Pet.getValue());
/* 138 */     mplew.write(0);
/* 139 */     mplew.writeInt(index);

/* 141 */     return mplew.getPacket();
   }

   public static byte[] loadExceptionList(MapleCharacter chr, MaplePet pet) {
/* 145 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 147 */     mplew.writeShort(SendPacketOpcode.PET_EXCEPTION_LIST.getValue());
/* 148 */     mplew.writeInt(chr.getId());
/* 149 */     mplew.writeInt(chr.getPetIndex(pet));
/* 150 */     mplew.writeLong(pet.getUniqueId());
/* 151 */     List<Integer> excluded = pet.getExcluded();
/* 152 */     mplew.write(excluded.size());
/* 153 */     for (Integer anExcluded : excluded) {
/* 154 */       mplew.writeInt(anExcluded.intValue());
     }

/* 157 */     return mplew.getPacket();
   }

   public static byte[] petStatUpdate(MapleCharacter chr) {
/* 161 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 163 */     mplew.writeShort(SendPacketOpcode.UPDATE_STATS.getValue());
/* 164 */     mplew.write(0);
/* 165 */     mplew.writeLong(MapleStat.宠物.getValue());
/* 166 */     MaplePet[] pets = chr.getSpawnPets();
/* 167 */     for (int i = 0; i < 3; i++) {
/* 168 */       if (pets[i] != null) {
/* 169 */         mplew.writeLong(pets[i].getUniqueId());
       } else {
/* 171 */         mplew.writeLong(0L);
       }
     }
/* 174 */     mplew.write(0);
/* 175 */     mplew.writeShort(0);

/* 177 */     return mplew.getPacket();
   }

   public static byte[] changePetColor(MapleCharacter player, MaplePet pet) {
/* 181 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 183 */     mplew.writeShort(SendPacketOpcode.PET_COLOR_CHANGE.getValue());
/* 184 */     mplew.writeInt(player.getId());
/* 185 */     mplew.writeInt(player.getPetIndex(pet));
/* 186 */     mplew.writeInt(pet.getColor());

/* 188 */     return mplew.getPacket();
   }
 }


/* Location:              C:\PGX\Server.jar!\tools\packet\PetPacket.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */